package com.gin.kotlin.no_gay_alliance.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.gin.kotlin.no_gay_alliance.database.entity.ReplyHistoryTask
import java.time.ZonedDateTime

@Dao
interface ReplyHistoryTaskDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun add(task: ReplyHistoryTask)

    @Update
    fun update(task: ReplyHistoryTask)

    @Query("select * from ReplyHistoryTask where id=:id")
    fun get(id: Int): ReplyHistoryTask?

    @Query("select * from ReplyHistoryTask")
    fun list(): List<ReplyHistoryTask>?

    @Query("delete from ReplyHistoryTask where id=:id")
    fun del(id: Int)

    @Query("update ReplyHistoryTask set status=:status,updatedTime=:time  where id=:id")
    fun setStatus(id: Int, status: ReplyHistoryTask.Status, time: ZonedDateTime = ZonedDateTime.now())
}
